package com.yetianhua.sqlsession;

import com.yetianhua.pojo.Configuration;
import com.yetianhua.xml.XmlConfigBuilder;

import java.io.InputStream;

/**
 * @author yetianhua
 * @className SqlSessionFactoryBuilder
 * @description TODO
 * @date 2021/5/30
 * @time 12:08
 */
public class SqlSessionFactoryBuilder {

    public static SqlSessionFactory build(InputStream in) throws Exception {
        // 1. 根据sqlMapConfig.xml生成configuration对象
        Configuration config = XmlConfigBuilder.build(in);
        // 2. 根据configuration对象生成SqlSessionFactory
        return new DefaultSqlSessionFactory(config);
    }

}
